﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class DocumentItemBL
	{

		#region ***** Init Methods ***** 
		DocumentItemDA objDocumentItemDA;
		public DocumentItemBL()
		{
			objDocumentItemDA = new DocumentItemDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get DocumentItem by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>DocumentItem</returns>
		public DocumentItem GetByID(int id)
		{
			return objDocumentItemDA.GetByID(id);
		}

		/// <summary>
		/// Get all of DocumentItem
		/// </summary>
		/// <returns>List<<DocumentItem>></returns>
		public List<DocumentItem> GetList()
		{
			string cacheName = "lstDocumentItem";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objDocumentItemDA.GetList(), "DocumentItem");
			}
			return (List<DocumentItem>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of DocumentItem
		/// </summary>
		/// <returns>DataSet</returns>
		public DataSet GetDataSet()
		{
			string cacheName = "dsDocumentItem";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objDocumentItemDA.GetDataSet(), "DocumentItem");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}


		/// <summary>
		/// Get all of DocumentItem paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<DocumentItem>></returns>
		public List<DocumentItem> GetListPaged(int recperpage, int pageindex)
		{
			return objDocumentItemDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of DocumentItem paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objDocumentItemDA.GetDataSetPaged(recperpage, pageindex);
		}





		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new DocumentItem within DocumentItem database table
		/// </summary>
		/// <param name="obj_documentitem">DocumentItem</param>
		/// <returns>key of table</returns>
		public int Add(DocumentItem obj_documentitem)
		{
			ServerCache.Remove("DocumentItem", true);
			return objDocumentItemDA.Add(obj_documentitem);
		}

		/// <summary>
		/// updates the specified DocumentItem
		/// </summary>
		/// <param name="obj_documentitem">DocumentItem</param>
		/// <returns></returns>
		public void Update(DocumentItem obj_documentitem)
		{
			ServerCache.Remove("DocumentItem", true);
			objDocumentItemDA.Update(obj_documentitem);
		}

		/// <summary>
		/// Delete the specified DocumentItem
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("DocumentItem", true);
			objDocumentItemDA.Delete(id);
		}
		#endregion
	}
}
